/* 
    获取报文中的 url路径:   pathname
                查询字符串: search | searchParams
*/

const http = require("http");
const logger = require("../_unit/logs");
const server = http.createServer((request, response) => {
  /* 方式1：通过 URL */
  let urlObj = new URL(request.url, "http://127.0.0.1:3000");

  let { pathname, searchParams } = urlObj;
  let a = searchParams.get("a");
  let b = searchParams.get("b");

  response.setHeader("Content-Type", "text/plain; charset=utf-8");
  /* 返回响应体 */
  response.end("nodejs 服务相应体!");
});

server.listen(3000, () => {
  console.log("开启3000服务!");
});
